#include "Stack.h"
using namespace std;

template <class T>
void Stack<T>::clear()
{
    m_size = 0;
    Node *p;
    while (m_top != nullptr)
    {
        p = m_top;
        m_top = m_top->next;
        delete p;
    }
}

template <class T>
void Stack<T>::Push(const T &val)
{
    Node *p = new Node(val, m_top);
    m_top = p;
    m_size++;
}

template <class T>
void Stack<T>::Pop()
{
    Node *p = m_top;
    m_top = m_top->next;
    delete p;
    m_size--;
}

template <class T>
T Stack<T>::Top() const
{
    return m_top->val;
}